﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using SD.Database.Classes;
using DBAccess;
using System.Collections.Generic;
namespace SD.Database
{
    public partial class UserFunctions
    {
        public static bool ChangePassword(int userId, string password)
        {
            int i = DAL.GetInstance().UpdateData("Update Players Set Password = @param0 Where PlayerId = @param1",
                new List<object>() { StaticMethods.GetMd5Sum(UserFunctions.PlayerName(userId) + password), userId });
                    if (i > 0) return true;
                    else return false;
        }
        public static Boolean AuthorizeUser(string user, string password)
        {
            if (DAL.GetInstance().GetScalar("Select Password From Players Where PlayerName = @param0", new List<object>(){user})
                    == StaticMethods.GetMd5Sum(user + password))
                return true;
            else
                return false;
        }
    };

}